# Contributor: Antoine Fontaine <antoine.fontaine@epfl.ch>
# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer:
pkgname=pantalaimon
pkgver=0.10.3
pkgrel=1
pkgdesc="E2EE-aware Matrix proxy daemon"
options="!check" # Tests hang
url="https://github.com/matrix-org/pantalaimon"
# ppc64le: blocked by py3-keyring
arch="noarch !ppc64le"
license="Apache-2.0"
depends="
	python3
	py3-attrs
	py3-aiohttp
	py3-brotlipy
	py3-appdirs
	py3-click
	py3-keyring
	py3-logbook
	py3-peewee
	py3-janus
	py3-cachetools
	py3-prompt_toolkit
	py3-matrix-nio
	"
checkdepends="
	py3-aioresponses
	py3-faker
	py3-hpack
	py3-hyperframe
	py3-pytest
	py3-pytest-aiohttp
	"
makedepends="py3-wheel py3-setuptools"
subpackages="$pkgname-ui $pkgname-doc"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/matrix-org/pantalaimon/archive/$pkgver.tar.gz
	"

build() {
	python3 setup.py build
}

check() {
	PYTHONPATH="$PWD/build/lib" python3 -m pytest
}

package() {
	python3 setup.py install --prefix=/usr --root="$pkgdir"

	cd "$srcdir/pantalaimon-$pkgver/docs/man"
	install -Dm 0644 panctl.1 "$pkgdir"/usr/share/man/man1/panctl.1
	install -Dm 0644 pantalaimon.5 "$pkgdir"/usr/share/man/man5/pantalaimon.5
	install -Dm 0644 pantalaimon.8 "$pkgdir"/usr/share/man/man8/pantalaimon.8
}

ui() {
	depends="
		$pkgname
		py3-gobject3
		py3-dbus
		py3-pydbus
		py3-notify2
		"
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/panctl "$subpkgdir"/usr/bin/
}


sha512sums="
07c30594a1105956affebae7250db4a80db605f80ce9abc61bd4b8f02605129a73e9375c6d5c09c0268025195bd6a43df1d870974d4d3a5d53d696342a08bcd9  pantalaimon-0.10.3.tar.gz
"
